<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>

		<script type="text/javascript">
			// 4. 根据课件动物类的例子，尝试定义更多的动物重写sound方法，比如：狗、猫等，至少3种。
			function Animal(type) {
				this.type = type;
			}
			Animal.prototype.sound = function() {
				console.log(this.type + "发出叫声");
			}

			function F() {}
			F.prototype = Animal.prototype;

			function Cow() {
				Animal.call(this, '牛');
				Cow.prototype.sound = function() {
					console.log(this.type + "哞哞叫");
					this.__proto__.__proto__.sound.call(this);
				}
			}
			Cow.prototype = new F();
			Cow.prototype.constructor = Cow;
			let cow = new Cow()
			cow.sound();
			
			function Dog() {
				Animal.call(this, '狗');
				Dog.prototype.sound = function() {
					console.log(this.type + "汪汪叫");
					this.__proto__.__proto__.sound.call(this);
				}
			}
			Dog.prototype = new F();
			Dog.prototype.constructor = Dog;
			let dog = new Dog()
			dog.sound();
			
			function Cat() {
				Animal.call(this, '猫');
				Cat.prototype.sound = function() {
					console.log(this.type + "喵喵叫");
					this.__proto__.__proto__.sound.call(this);
				}
			}
			Cat.prototype = new F();
			Cat.prototype.constructor = Cat;
			let cat = new Cat()
			cat.sound();
		</script>
	</body>
</html>
